#ifndef EVENTMANAGER_H
#define EVENTMANAGER_H

#include "Export.h"
#include "GL/glfw.h"

#define NBKEYS 512
#define NBMOUSEBUTTONS 3

namespace glow
{
	class SHARED EventManager
	{
		public:

		void init(bool keyRepeat = true, bool stickykeys = true, bool stickyMouseButtons = true);

		void getEvent();

		bool isKeyDownOnce(int key);
		bool isKeyDown(int key) const;

		bool isMouseButtonUp(int button) const;

		int getMouseX() const;
		int getMouseY()const;
		int getRelMouseX() const;
		int getRelMouseY() const;

		bool quit() const;

		void eventKeyCB(int key, int action);
		void eventMouseCB(int x, int y);
		void eventMouseButtonCB(int button, int action);
		
		/*make singleton*/
		static EventManager *getInstance();
		static void destroy();

		private:

		EventManager();
		~EventManager();
		
		int _keyDown[NBKEYS], _keyOnce[NBKEYS];
		int _mouseButton[NBMOUSEBUTTONS];

		int _mouseX, _mouseY, _lastMouseX, _lastMouseY, _relX, _relY;

		bool _quit;
		
		/*make singleton*/
		static EventManager *_inst;
	};
}

#endif
